import com.myProject.bean.TThing;
import com.myProject.dao.ThingDao;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import util.SqlSessionUtil;

import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class test {
    private SqlSession sqlSession;
    Logger log = Logger.getLogger(test.class);

    @Before
    public void init(){
        String config = "mybatis-configuration.xml";
        InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(config);
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        sqlSession = factory.openSession();
    }

    @Test
    public void testTime() throws ParseException {
//        ThingDao td = sqlSession.getMapper(ThingDao.class);
//        HashMap<String,Object>map = new HashMap();
//        String da1 = "2019-1-1";
//        String da2 = "2020-1-3";
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//
//        Date d1 = new Date();
//        d1 = sdf.parse(da1);
//        Date d2 = sdf.parse(da2);
//        map.put("startTime",da1);
//        map.put("endTime",da2);
////        List<TThing>list = td.getThingsList(map);
//        log.info(list);
//        sqlSession.commit();
    }
    @Test
    public void testTimes(){
//        Date d =new Date();
//        System.out.println("d = " + d);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        try {
//          Date dd=  sdf.parse(d);
//            System.out.println("dd = " + dd);
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
    }

}
